﻿using LJ.Abstractions.DependencyInjection;

namespace LJ.Host.Web.Middleware;


public class HybridServiceMiddleware(RequestDelegate next)
{
    private readonly RequestDelegate _next = next;

    public async Task InvokeAsync(HttpContext context)
    {
        using var cancellationTokenHybridProviderHandler = context.RequestServices.GetRequiredService<IHybridProviderHandler<CancellationToken>>();
        cancellationTokenHybridProviderHandler.Execute(context.RequestAborted);

        using var serviceProviderHybridProviderHandler = context.RequestServices.GetRequiredService<IHybridProviderHandler<IServiceProvider>>();
        serviceProviderHybridProviderHandler.Execute(context.RequestServices);

      
        // 继续处理请求
        await _next(context);

    }
}